package com.dxf.bigdata.D04_spark

import scala.io.StdIn
import java.io.{ObjectOutputStream, OutputStream}
import java.net.Socket

object T01_Driver {
  def main(args: Array[String]): Unit = {
    val client1 = new Socket("localhost", 9999)
    val client2 = new Socket("localhost", 8888)
    val os1: OutputStream = client1.getOutputStream
    val os2: OutputStream = client2.getOutputStream
    val objOs1: ObjectOutputStream = new ObjectOutputStream(os1)
    val objOs2: ObjectOutputStream = new ObjectOutputStream(os2)
    while (true) {
      println("请输入")
      val name: Int = StdIn.readLine().toInt
      val task = new T01_Task //总task

      val task1 = new T01_SubTask // 第一个任务,给到一个Executor
      val task2 = new T01_SubTask // 第二个任务,给到另一个Executor

      task1.datas=task.datas.take(2)
      task2.datas=task.datas.takeRight(2)
      task1.logic=task.logic
      task2.logic=task.logic

      objOs1.writeObject(task1)
      objOs1.flush()

      objOs2.writeObject(task2)
      objOs2.flush()
    }


    client1.close()
    client2.close()
  }
}
